Skip to content

MVP authentication backend implementation#1121

Open
curty wants to merge 16 commits intojtleek:masterfrom
curty:cursor/mvp-auth-backend
Open

MVP authentication backend implementation#1121
curty wants to merge 16 commits intojtleek:masterfrom
curty:cursor/mvp-auth-backend

Conversation

@curty
Copy link

@curty curty commented Jan 23, 2026

Implements the MVP authentication backend per schema/AUTHENTICATION_FLOWS.md.
Backend-only, session-based auth with PostgreSQL.

curty and others added 16 commits January 23, 2026 15:25
Added complete technical specification for CloudPeople project, including tech stack, database schema, API endpoints, page structure, UI components, real-time architecture, security measures, development phases, and deployment details.
Based on CP Build 1 specification:
- users table: core authentication with role-based access
- sessions table: token-based session management
- candidates table: job-seeker profiles with auction floor (min_salary)
- employers table: company profiles with verification workflow

Includes enums, indexes, and detailed rationale document.

Co-authored-by: eoghan <eoghan@cloudpeople.ai>
Changes:
- Remove candidates and employers tables (marketplace-specific)
- Replace with minimal user_profiles table (identity only)
- Remove salary, skills, domains, visibility flags
- Document auth strategy options instead of choosing one
- Keep rationale comments throughout

Co-authored-by: eoghan <eoghan@cloudpeople.ai>
…schema-060c

User authentication profiles schema
- Document email/password authentication flow (registration, login, reset)
- Document optional OAuth authentication flow with linking strategies
- Analyze session management options (DB sessions, JWT, hybrid)
- Document trade-offs for each approach
- Recommend MVP configuration: email/password + bcrypt + DB sessions
- No code, no vendor lock-in, standards-based approach

Co-authored-by: eoghan <eoghan@cloudpeople.ai>
- Add package.json with pg, bcrypt, zod dependencies (no ORM)
- Add TypeScript configuration
- Add Next.js and ESLint configuration
- Add environment example and gitignore
- Add minimal app layout and page

Co-authored-by: eoghan <eoghan@cloudpeople.ai>
Raw SQL migrations (no ORM):
- 001: users table with role enum
- 002: user_profiles table
- 003: sessions table for DB-backed sessions
- 004: email_verification_tokens table
- 005: password_reset_tokens table (1-hour expiry)
- 006: oauth_accounts table (scaffolding only)

Includes simple migration runner script (scripts/migrate.js)

Co-authored-by: eoghan <eoghan@cloudpeople.ai>
- Raw SQL query helpers using pg library
- Connection pooling with singleton pattern
- queryOne/queryAll convenience functions
- generateId for unique IDs

Co-authored-by: eoghan <eoghan@cloudpeople.ai>
- Password hashing with bcrypt (cost factor 12)
- Token generation and hashing with crypto
- Zod validation schemas for all auth inputs
- Token duration constants per design doc

Co-authored-by: eoghan <eoghan@cloudpeople.ai>
- Database-backed sessions with HttpOnly cookies
- Session creation, validation, and deletion
- Cookie helpers for secure session management
- Standardized API response format
- Common error responses

Co-authored-by: eoghan <eoghan@cloudpeople.ai>
- Validates email, password, role, firstName, lastName
- Checks for existing email (prevents enumeration)
- Creates user + profile + verification token in transaction
- Establishes session with HttpOnly cookie
- Logs verification token in dev mode

Co-authored-by: eoghan <eoghan@cloudpeople.ai>
- Validates email and password input
- Generic error message prevents email enumeration
- Verifies password with bcrypt
- Updates last_login timestamp
- Creates session with optional rememberMe (30 days)

Co-authored-by: eoghan <eoghan@cloudpeople.ai>
logout:
- Deletes session from database
- Clears session cookie

me:
- Returns current user with profile data
- Returns 401 if not authenticated
- Includes session expiration info

Co-authored-by: eoghan <eoghan@cloudpeople.ai>
verify-email:
- POST: Verify with token, marks email_verified
- GET: Resend verification email (requires auth)

forgot-password:
- Always returns success (prevents enumeration)
- Creates 1-hour expiry token

reset-password:
- Validates token (1-hour expiry per design doc)
- Updates password, invalidates all sessions

Co-authored-by: eoghan <eoghan@cloudpeople.ai>
- Google and GitHub provider configurations
- Providers only enabled when env vars are set
- Helper functions to check OAuth status
- Updated .env.example with OAuth vars (commented out)

Co-authored-by: eoghan <eoghan@cloudpeople.ai>
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed: backend-only MVP auth per AUTHENTICATION_FLOWS.md.
Session-based auth, email/password primary, OAuth scaffold only.
Looks good to merge.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants